tests: Avoid generating lots of output in itest-payload-link
authorColin Walters <walters@verbum.org>
Mon, 12 Mar 2018 22:02:04 +0000 (18:02 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 13 Mar 2018 13:05:27 +0000 (13:05 +0000)
We noticed this in a recent PR.  While I'm here, also only do
the `find` once, add `-type l` for good measure, and use our
built in `libtest.sh` assertion functions.

Closes: #1494
Approved by: giuseppe

tests/installed/itest-payload-link.sh

index a0764a076c5cbb5f852c0dae6671808e0859f458..807d497d8b6254d1c794904950ec737f5d82fc6e 100755 (executable)
@@ -68,18 +68,17 @@ if cp --reflink a b; then
     ostree config --repo=repo set core.payload-link-threshold 0
     ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
     ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref}
-    if test `find repo -name '*.payload-link' | wc -l` = 0; then
-        fatal ".payload-link files not found"
-    fi
+    find repo -type l -name '*.payload-link' >payload-links.txt
+    assert_not_streq "$(wc -l < payload-links.txt)" "0"
 
-    find repo -name '*.payload-link' | while read i;
-    do
+    # Disable logging for inner loop, otherwise it'd be enormous
+    set +x
+    cat payload-links.txt | while read i; do
         payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)
         payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1)
-        if test $payload_checksum != $payload_checksum_calculated; then
-            fatal ".payload-link has the wrong checksum"
-        fi
+        assert_streq "${payload_checksum}" "${payload_checksum_calculated}"
     done
+    set -x
     echo "ok pull creates .payload-link"
 else
     echo "ok # SKIP no reflink support in the file system"